<div class="pts_test_progress_area" id="benchmark_status_window">
<div id="pts_circle"></div>
<script type="text/javascript">
pts_set_completion_circle(0, "Benchmark", "pts_circle");
</script>
<p>The Phoronix Test Suite is currently running the <strong id="currently_running_test_sentence"></strong> benchmark. It's estimated this test will finish in approximately <strong id="time_to_current_test_finish"></strong>. The test is on its <strong id="current_test_run_pos" style="text-transform: lowercase;"></strong> of expected <strong id="current_test_run_total" style="text-transform: lowercase;"></strong> trial runs<span id="current_test_run_extra_string"></span>. The Phoronix Test Suite is running test <strong id="current_test_queue_pos" style="text-transform: lowercase;"></strong> of <strong id="current_test_queue_total" style="text-transform: lowercase;"></strong> currently in the test queue. It's estimated the testing will be complete within <strong id="test_queue_estimated_run_time"></strong>.</p>
</div>
<div id="svg_graphs" style="margin: 10px 0; text-align: center;"></div>
<script text="text/javascript">
pts_web_socket.add_onopen_event("user-svg-system-graphs");
setInterval(function(){if(pts_web_socket.is_connected()) { pts_web_socket.send("user-svg-system-graphs"); }}, 5000);
pts_web_socket.add_onmessage_event("svg_graphs", "update_svg_graph_space");

function update_benchmark_state(j)
{
	if(j.pts.msg.current_state == "complete")
	{
		var benchmark_complete = "<h1>Benchmark Complete</h1>";
		benchmark_complete += "<p>The <strong>" + j.pts.msg.result_identifier + "</strong> run within <strong>" + j.pts.msg.result_title + "</strong> [<em>" + j.pts.msg.result_file_name + "</em>] is complete.</p>";
		if(j.pts.msg.result_url && j.pts.msg.result_url.length > 1)
		{
			benchmark_complete += "<h2>View The Benchmark Results: <a target=\"_blank\" href=\"" + j.pts.msg.result_url + "\">" + j.pts.msg.result_url + "</a></h2>";
		}
		document.getElementById("benchmark_status_window").innerHTML = benchmark_complete;
	}
    else if(j.pts.msg.current_state == "failed")
    {
        var benchmark_failed = "<h1>Benchmark Failed</h1>";
        benchmark_failed += "<p><strong>" + j.pts.msg.error + "</p>";

        document.getElementById("benchmark_status_window").innerHTML = benchmark_failed;

    }
	else
	{
		// current_state = benchmark
		current_test_profile = JSON.parse(atob(j.pts.msg.current_test));
		document.getElementById("currently_running_test_sentence").innerHTML = current_test_profile.TestInformation.Title;
		document.getElementById("current_test_run_pos").innerHTML = pts_number_to_string(j.pts.msg.test_run_pos);
		document.getElementById("current_test_run_total").innerHTML = pts_number_to_string(j.pts.msg.test_run_total);
		var current_test_offset = j.pts.msg.test_run_pos > j.pts.msg.test_run_total ? 1 : '';
		document.getElementById("current_test_run_extra_string").innerHTML = current_test_offset == 1 ? ' as additional test runs were required for greater accuracy' : '';
		var test_completeness = j.pts.msg.test_run_pos / ((+j.pts.msg.test_run_total + 1) + current_test_offset);
		document.getElementById("time_to_current_test_finish").innerHTML = pts_seconds_to_pretty_string(Math.round(j.pts.msg.test_run_estimated_time * (1 - test_completeness)));
		//pts_set_completion_circle((test_completeness * 100), current_test_profile.TestInformation.Title, "pts_left_circle");
		document.getElementById("current_test_queue_pos").innerHTML = pts_number_to_string(j.pts.msg.test_queue_pos);
		document.getElementById("current_test_queue_total").innerHTML = pts_number_to_string(j.pts.msg.test_queue_total);
		document.getElementById("test_queue_estimated_run_time").innerHTML = pts_seconds_to_pretty_string(j.pts.msg.test_queue_estimated_run_time);
		//pts_set_completion_circle(((j.pts.msg.test_queue_pos - 1 + test_completeness) / j.pts.msg.test_queue_total * 100), "Overall Progress", "pts_right_circle");

		if(j.pts.msg.test_queue_total > 1)
		{
			var circle_percents = new Array(((j.pts.msg.test_queue_pos - 1 + test_completeness) / j.pts.msg.test_queue_total * 100), (test_completeness * 100));
			var circle_text = new Array("Benchmarking", current_test_profile.TestInformation.Title);
			pts_set_completion_circle_array(circle_percents, circle_text, "pts_circle");
		}
		else
		{
			pts_set_completion_circle((test_completeness * 100), current_test_profile.TestInformation.Title, "pts_circle");
		}
	}
}
if(localStorage.test_queue_submit)
{
	pts_web_socket.submit_event("run-benchmark-queue " + localStorage.test_queue_submit, "benchmark_state", "update_benchmark_state");
	localStorage.test_queue_submit = "";
	localStorage.test_queue = "";
	update_benchmark_button();
}

</script>
